package elijah.base.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.FrameLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.viewbinding.ViewBinding;

import elijah.base.thread.ScheduledProvider;
import elijah.base.utils.ClassUtils;

public abstract class BaseWidget<V extends ViewBinding> extends FrameLayout {
    protected V binding;

    public BaseWidget(@NonNull Context context) {
        this(context, null);
    }

    public BaseWidget(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        binding = (V) ClassUtils.getViewBinding(getClass(), 0, this, true);
        initView(attrs);
        addOnAttachStateChangeListener(ScheduledProvider.instance());

    }

    public V getViewBinding() {
        return binding;
    }

    public abstract void initView(@Nullable AttributeSet attrs);



}
